﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.Infrastructure;

namespace YunZiChanApi.Yunbo
{
    /// <summary>
    /// 封装自定义控制器基类
    /// </summary>
    public class BaseController : ControllerBase
    {

        /// <summary>
        /// 返回成功
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        protected IActionResult Success(object message)
        {
            return Ok(new { success = true, message });
            //return StatusCode(200, new { success = true, message = message });
        }

        /// <summary>
        /// 返回失败
        /// </summary>
        /// <param name="errorMessage"></param>
        /// <returns></returns>
        protected IActionResult Error(string errorMessage)
        {
            return StatusCode(500, new { success = false, error = errorMessage });
        }

    }
}
